package com.wtf.dsp.admin.core.config;

import com.wtf.dsp.admin.core.dao.AbstractJdbcDao;
import com.wtf.dsp.admin.core.executor.WtfDynamicDataSourceMybatisConfigExecutor;
import com.wtf.dsp.admin.core.executor.WtfDynamicDataSourceProviderExecutor;
import com.wtf.dsp.admin.core.provider.DynamicDataSourceConfigProvide;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: WtfDspExecutorConfig
 * Description:
 * date: 2024/3/14 11:46
 *
 * @author linhuanyou
 * @version 1.0
 */
@AutoConfigureAfter(WtfDspAdminConfig.class)
@Configuration
public class WtfDspExecutorConfig {

    @Bean
    public DynamicDataSourceConfigProvide dynamicDataSourceConfigProvide(){
        return new DynamicDataSourceConfigProvide();
    }

    @Bean
    public WtfDynamicDataSourceProviderExecutor dynamicDataSourceExecutor(WtfDspAdminConfig wtfDspMapperConfig, DynamicDataSourceConfigProvide dynamicDataSourceConfigProvide, AbstractJdbcDao abstractJdbcDao){
        return new WtfDynamicDataSourceProviderExecutor(wtfDspMapperConfig,dynamicDataSourceConfigProvide,abstractJdbcDao);
    }

    @Bean
    public WtfDynamicDataSourceMybatisConfigExecutor dataSourceMybatisConfigExecutor(WtfDspAdminConfig wtfDspMapperConfig, WtfDynamicDataSourceProviderExecutor dataSourceProvider){
        return new WtfDynamicDataSourceMybatisConfigExecutor(wtfDspMapperConfig,dataSourceProvider);
    }

}
